<template>
<div>
  <el-descriptions class="margin-top" title="个人信息" :column="2" :size="size" border>
<!--    <template slot="extra">-->
<!--      <el-button type="primary" size="small">操作</el-button>-->
<!--    </template>-->
    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-user"></i>
        姓名
      </template>
      {{studentName}}
    </el-descriptions-item>
    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-mobile-phone"></i>
        学号
      </template>
      {{studentNo}}
    </el-descriptions-item>
    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-location-outline"></i>
        验证码
      </template>
      {{verifyCode}}
    </el-descriptions-item>
<!--    <el-descriptions-item>-->
<!--      <template slot="label">-->
<!--        <i class="el-icon-tickets"></i>-->
<!--        备注-->
<!--      </template>-->
<!--      <el-tag size="small">学校</el-tag>-->
<!--    </el-descriptions-item>-->
    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-office-building"></i>
        邮箱
      </template>
      {{email}}
    </el-descriptions-item>
  </el-descriptions>
</div>
</template>

<script>
import axios from "axios";

export default {
  name: "Info",
  data(){
    return{
      size: '',
      studentName: '',
      studentNo: '',
      verifyCode: '',
      email: '',
    }
  },
  created() {
    let token = localStorage.getItem("token")
    let username = localStorage.getItem("username")
    let obj = {
      "username": username,
      "token": token
    }

    axios.defaults.withCredentials = true
    document.cookie = 'access-token' + token

    this.$axios.post("http://localhost:8090/user/info",obj)
    .then(res => {
      if(res.data.code == 200){
        this.studentName =  res.data.result.studentName
        this.studentNo =  res.data.result.studentNo
        this.verifyCode =  res.data.result.verifyCode
        this.email =  res.data.result.email

      }else{
        alert(res.data.message)
      }
    })
  }
}
</script>

<style scoped>

</style>